package com.qf;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * projectName: MyBatis_1
 *
 * @author: MaTianWei
 * time: 2021/6/23 22:49
 * description:
 */

public class SelectTest {
    public static void main(String[] args) throws IOException {
        //1·加载配置文件
        InputStream stream = Resources.getResourceAsStream("mybatis_config.xml");
        //2·创建一个sqlSessionFactoryBuilder
        SqlSessionFactoryBuilder factoryBuilder = new SqlSessionFactoryBuilder();
        //3·创建sqlSessionFactory
        SqlSessionFactory sqlSessionFactory = factoryBuilder.build(stream);
        //4·创建sqlSession
        //SqlSession session = sqlSessionFactory.openSession(false);
        SqlSession session = sqlSessionFactory.openSession();
        //5·sqlSession进行数据库操作
        Object obj = session.selectOne("x.x.x.selectShoppingID", 22);
        System.out.println("obj内容："+obj);
        //6·资源关闭 事务提交
        //session.commit();
        session.close();
    }

}
